//
// Forms
// --------------------------------------------------

// Inline forms
//

.form-inline {
  .form-control {
    margin-bottom: 10px;
  }

  .checkbox label,
  .radio label {
    margin-bottom: 0;
  }

  @media (min-width: @screen-tablet) {
    .form-control {
      margin-bottom: 0;
      width: auto;
    }
  }
}

// Horizontal forms
//

.form-horizontal {
  .checkbox,
  .radio {
    margin-top: 0px;
    margin-bottom: 0px;
  }

  .control-label {
    padding-top: 0;
    margin-bottom: 5px;
  }
}

@media (min-width: @screen-tablet) {
  .form-horizontal .control-label {
    margin-bottom: 0;
    padding-top: 7px;
  }
}


// Elements
//

legend {
  color: #666;
  font-size: (@font-size-base * 1.3);
  padding-bottom: 7px;
}

label {
  font-weight: 600;
}

optgroup {
  font-weight: 600;
}

.form-control {
  border-top-color: darken(@input-border, 8%);
  .box-shadow(none);
}

// Help block
.help-block {
  margin-bottom: 0;
}

.form-group {
  .clearfix();
}

.form-group.has-error {
  .checkbox .help-block,
  .radio .help-block,
  .checkbox + .help-block,
  .radio + .help-block {
    position: relative;
    top: 5px;
    
    &:before, &:after {
      display: none;
    }
  }
}

.checkbox label,
.radio label {  
  display: block;
  margin-bottom: 0;
  .clearfix();
}

// Form control icons
//

.form-control-feedback {
  font-size: 14px;
}

.has-feedback .form-control {
  padding-right: 32px;
}

.form-bordered .form-group {
  border-top: 1px solid @table-border-color;
  padding-top: 15px;
}

.checkbox,
.radio {
  margin-top: 0;
}


// Form states
//

// Common
.has-warning, .has-error, .has-success {
  .help-block {
    display: block;
    border: 1px solid;
    padding: 5px 10px;
    
    border-radius: 2px;
    margin-top: 2px;
    position: relative;

    // Add carets to the form messages
    //

    &:before, &:after {
      content: "";
      position: absolute;
      border-left: 6px solid transparent;
      border-right: 6px solid transparent;
    }

    &:before {
      border-bottom: solid;
      border-width: 7px;
      left: 16px;
      top: -7px;
    }
    
    &:after{
      border-bottom: 6px solid;
      left: 17px;
      top: -6px;
    }
  }

  // Simple form messages
  //

  &.simple .help-block {
    background: none !important;
    border: none;
    padding: 3px 0;

    &:before, &:after {
      display: none;
    }
  }
}


// Forms states
//

.has-feedback:not(.form-group) {
  position: relative;

  .form-control-feedback {
    top: 0;
  }
}

// Warning
.has-warning {
  .pixel-form-state-light(#f9f1c7, #af8640, #f6deac);
}
// Error
.has-error {
  .pixel-form-state-light(#f2dede, #b94a48, #ebccd1);
}
// Success
.has-success {
  .pixel-form-state-light(#dff0d8, #468847, #d0e6be);
}

// Warning
.has-warning.dark {
  .pixel-form-state-dark(@warning-color, #f6deac);
}
// Error
.has-error.dark {
  .pixel-form-state-dark(@danger-color, #ebccd1, @stripes-opacity: .04);
}
// Success
.has-success.dark {
  .pixel-form-state-dark(@success-color, #d0e6be);
}

// Warning
.has-warning.simple {
  .pixel-form-state-simple(darken(@warning-color, 8%));
}
// Error
.has-error.simple {
  .pixel-form-state-simple(darken(@danger-color, 8%));
}
// Success
.has-success.simple {
  .pixel-form-state-simple(darken(@success-color, 8%));
}


// Styled checkboxes and radios
// --------------------------------------------------

.gt-ie8 {
  input.px {
    position: absolute !important;
    left: -1000000px !important;
    margin: 0 !important;
    padding: 0 !important;

    & + .lbl {
      position: relative;
      padding-left: 1px;
      display: inline-block;

      &:before {
        content: "";
        opacity: 1;
        border: 1px solid #bbb;
        background: #fff;
        display: block;
        position: absolute;
        top: 0;
        left: 0;
        width: 15px;
        height: 15px;
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
        -webkit-transition: all 0.2s;
        transition: all 0.2s;
        cursor: pointer;
      }

      &:after {
        display: none;
        position: absolute;
      }
    }

    &:checked + .lbl:after {
      display: block;
    }

    & + .lbl:before,
    & + .lbl:after {
      margin: 2px 3px -3px -20px !important;
    }
  }

  input[type="checkbox"].px {
    & + .lbl:before {
      border-radius: @border-radius-base;
    }

    & + .lbl:after {
      content: "\f00c";
      top: 1px;
      left: 1px;
      width: 13px;
      height: 15px;
      line-height: 15px;
      font-size: 11px;
      font-family: FontAwesome;
      text-align: center;
    }
  }

  input[type="radio"].px {
    & + .lbl:before {
      border-radius: 999999px;
    }

    & + .lbl:after {
      content: "";
      width: 5px;
      height: 5px;
      border-radius: 999px;
      top: 5px;
      left: 5px;
    }
  }

  input.px:disabled,
  input.px.disabled {
    &,
    & + .lbl,
    & + .lbl:before,
    & + .lbl:after {
      cursor: not-allowed !important;
    }

    & + .lbl:before {
      background: #eee !important;
      border-color: #d6d6d6 !important;
    }

    & + .lbl:after {
      opacity: .5 !important;
    }
  }
}

@media (min-width: 768px) {
  .gt-ie8 .form-inline .radio input.px + .lbl,
  .gt-ie8 .form-inline .checkbox input.px + .lbl {
    margin-left: 20px;
  }
}

// Single checkboxes and radios
.px-single {
  position: relative;
  width: 15px;
  height: 15px;
  margin: 0;
  font-weight: 400 !important;

  input.px {
    margin: 0 !important;

    & + .lbl:before,
    & + .lbl:after {
      margin: 0 !important;
    }
  }

  input.px + .lbl {
    padding: 0 !important;
    width: 15px !important;
    height: 15px !important;
  }
}
